FROM alpine:3.19

ENV PHPIZE_DEPS="autoconf dpkg-dev dpkg file tar zip g++ gcc libc-dev make pkgconf re2c pcre-dev pcre2-dev zlib-dev libtool automake"

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

COPY ./run.sh /run.sh

RUN apk update \
    && apk upgrade \
    && apk add php82 \
    php82-pear \
    php82-dev \
    openssl \
    curl \
    tzdata \
    bash \
    ca-certificates \
    libaio-dev \
    openssl-dev \
    curl-dev \
    php82-mysqli \
    php82-pdo_mysql \
    php82-pdo_sqlite \
    php82-sqlite3 \
    php82-mbstring \
    php82-json \
    php82-zlib \
    php82-gd \
    php82-intl \
    php82-gmp \
    php82-session \
    php82-fpm \
    php82-curl \
    php82-posix \
    php82-fileinfo \
    php82-simplexml \
    php82-opcache  \
    php82-sodium \
    php82-tokenizer \
    php82-ctype \
    php82-bcmath \
    php82-openssl \
    php82-dom \
    php82-iconv \
    php82-sockets \
    php82-zip \
    php82-pcntl \
    php82-xmlwriter \
    php82-xmlreader \
    php82-redis \
    php82-xml \
    php82-phar \
    php82-pecl-xlswriter \
    php82-pecl-event \
    && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
    && cp "/usr/share/zoneinfo/Asia/Shanghai" /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone \
    && update-ca-certificates \
    #添加 www用户组和用户
    && addgroup -g 1000 www \
    && adduser -u 1000 -D -S -G www www \
    && mkdir /www  \
    && chown www:www /www \
    && chmod 1777 /www \
    && apk add gnu-libiconv libstdc++ --no-cache --repository http://mirrors.aliyun.com/alpine/edge/community/ --allow-untrusted \
    && ln -s /usr/sbin/php-fpm82 /usr/sbin/php-fpm \
    #&& ln -s /usr/bin/php82 /usr/bin/php \
    #&& ln -s /usr/bin/phar82 /usr/bin/phar \
    #&& ln -s /usr/bin/php-config82 /usr/bin/php-config \
    #&& ln -s /usr/bin/phpize82 /usr/bin/phpize \
    #&& ln -s /usr/bin/pecl82 /usr/bin/pecl \
    && chmod +x /run.sh \
    && wget -O /usr/local/bin/composer https://mirrors.tencent.com/composer/composer.phar \
    && chmod 755 /usr/local/bin/composer \
     # ---------- clear works ----------
    #&& apk del .build-deps \
    && rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/local/bin/php* \
    && composer config -g repos.packagist composer https://mirrors.huaweicloud.com/repository/php/

WORKDIR /www

EXPOSE 9000

CMD ["/run.sh"]